﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace AutoChess
{
    public enum ActionQueueType
    {
        /// <summary> 调整阶段开始</summary>
        AdjustStart,
        /// <summary> 战斗开始 </summary>
        BeginFight,
        /// <summary> 战斗结束 </summary>
        EndFight,
    }
    public class ActionQueueCtr
    {
        private Dictionary<ActionQueueType, ActionQueueList> queueMap = new Dictionary<ActionQueueType, ActionQueueList>();
        public ActionQueueCtr()
        {
            Init();
        }
        public void Init()
        {
            queueMap = new Dictionary<ActionQueueType, ActionQueueList>();
            queueMap[ActionQueueType.AdjustStart] = new ActionQueueList();
            queueMap[ActionQueueType.BeginFight] = new ActionQueueList();
            queueMap[ActionQueueType.EndFight] = new ActionQueueList();
        }
        public void StartActionQueue(ActionQueueType type,Action forceEnd)
        {
           // if (!queueMap[type].Runing)
            {
                queueMap[type].ActionQueueStart(forceEnd);
            }
        }
        public void ForceEndActionQueue(ActionQueueType type)
        {
            queueMap[type].ActionQueueStop();
        }
        public void AddQueueAction(ActionQueueType type,Action action, float delayTime, int priority)
        {
            queueMap[type].EnqueueAction(action, delayTime, priority);
        }
        public void AddQueueAction(ActionQueueType type,ActionObject oneAction)
        {
            queueMap[type].EnqueueAction(oneAction);
        }

        public void Tick()
        {
            var itor = queueMap.GetEnumerator();
            while (itor.MoveNext())
            {
                itor.Current.Value.Tick(Time.deltaTime);
            }
        }

        public void Relase()
        {
            var itor = queueMap.GetEnumerator();
            while (itor.MoveNext())
            {
                itor.Current.Value.Relase();
            }
            queueMap.Clear();
        }
    }
}









